package GUI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FrontPage extends JPanel {
        private static final int DEFAULT_WIDTH = 800;
        private static final int DEFAULT_HEIGHT = 600;
        public FrontPage(){
            setLayout(new BorderLayout());
            setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);

            JLabel label_north = new JLabel("口算练习系统");
            label_north.setBounds(0,50,300,100);
            label_north.setFont(new Font("微软雅黑",Font.PLAIN,20));
            label_north.setHorizontalAlignment(SwingConstants.CENTER);
            add(label_north,BorderLayout.NORTH);


            JPanel jPanel = new JPanel();
            jPanel.setLayout(null);
            jPanel.setFont(new Font("微软雅黑",Font.PLAIN,14));
            add(jPanel,BorderLayout.CENTER);


            JButton jButton1 = new JButton("创建新的习题");
            jButton1.setBounds(350,50,150,50);
            jButton1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    JPanel panel = new Generation_Exercises_Panel();
                      removeAll();
                      add(panel);
                      validate();
                }
            });
            jPanel.add("Center",jButton1);

            JButton jButton2 = new JButton("继续上次习题");
            jButton2.setBounds(350,150,150,50);
            jButton2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    ContinueExercisesPanel panel = new ContinueExercisesPanel();
                    removeAll();
                    add(panel);
                    validate();
                }
            });
            jPanel.add("Center",jButton2);


            JButton jButton3 = new JButton("浏览做题记录");
            jButton3.setBounds(350,250,150,50);
            jButton3.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    DisplayRecordPanel panel = new DisplayRecordPanel();
                    removeAll();
                    add(panel);
                    validate();
                }
            });
            jPanel.add("Center",jButton3);
            jPanel.setVisible(true);

            JLabel label_south = new JLabel("书山有路勤为径，学海无涯苦作舟");
            label_south.setFont(new Font("微软雅黑",Font.PLAIN,16));
            label_south.setVisible(true);
            label_south.setHorizontalAlignment(SwingConstants.CENTER);
            label_south.setVerticalAlignment(SwingConstants.BOTTOM);
            add(label_south,BorderLayout.SOUTH);
        }

        public static void main(String[] args) {
            JFrame frame = new JFrame();
            frame.setSize(852,600);
            frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            frame.setLocationRelativeTo(null);
            frame.add(new FrontPage());
            frame.setVisible(true);
        }
}

